package net.taiqin.tqerp.service.impl.fnd;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.taiqin.tqerp.controller.param.fnd.UserInfoParam;
import net.taiqin.tqerp.dao.fnd.IFndUserDao;
import net.taiqin.tqerp.domain.fnd.FndUserVO;
import net.taiqin.tqerp.service.fnd.IFndUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

@Service
public class FndUserServiceImpl implements IFndUserService {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private IFndUserDao userDao;

    public FndUserVO findFndUser(UserInfoParam param) {
        FndUserVO userInfo = new FndUserVO();
        Map<String, Object> map = new HashMap();
        map.put("loginName", param.getLoginName());
        map.put("password", param.getPassword());
        map.put("tenantId", param.getTenantId());
        this.userDao.findFndUser(map);
        List<FndUserVO> userInfoList = (List)map.get("x_user_info");
        if (!CollectionUtils.isEmpty(userInfoList)) {
            BeanUtils.copyProperties(userInfoList.get(0), userInfo);
        }

        userInfo.setStatus(String.valueOf(map.get("x_status")));
        userInfo.setMessage(String.valueOf(map.get("x_message")));
        return userInfo;
    }
}
